<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

class IndexXcx
{
    public $login = false; //是否需要登录才能访问该接口
    public $title = "小程序首页数据";
    public $group = '小程序首页';
    public $desc = "";

    public $input = [
    ];

    public $output = [
        'mall_home_banner' => [
            [
                'title' => 'label=对应类型的id;',
                'pic' => 'label=图标;',
                'link' => 'label=点击后前进路径;',
            ]
        ],
        'index_button' => [
            [
                'title' => 'label=对应类型的id;',
                'pic' => 'label=图标;',
                'link' => 'label=点击后前进路径;',
            ]
        ],
        'eyes_test' => [
            [
                'id' =>'label=id;',
                'title' => 'label=分享标题;',
                'content' => 'label=点击后前进路径;',
                'logo' => 'label=图标;',
                'sharepic' => 'label=分享图片;',
            ]
        ],
        'indexopen1' => 'int,label=首页档案板块是否显示',
        'indexopen2' => 'int,label=首页测试板块是否显示',
        'indexopen3' => 'int,label=首页科普板块是否显示',
        'sitelogo' => 'int,label=默认分享图片',
    ];

    public function run($param, $uid)
    {
        //轮播图
        $result['mall_home_banner'] = (array)M('poster')->where(['category' => 'mall_home_banner'])->order('level desc')->select();
        foreach($result['mall_home_banner'] as &$item){
            $item['pic'] = get_cover($item['pic'], 'url');
        }
        //首页按钮
        $result['index_button'] = (array)M('poster')->where(['category' => 'index_button'])->order('level asc')->select();
        foreach($result['index_button'] as &$item){
            $item['pic'] = get_cover($item['pic'], 'url');
        }
        //视力测试
        $result['eyes_test'] = (array)M('eyes_test')->where(['status' => 1])->order('px asc')->select();
        foreach($result['eyes_test'] as &$item){
            $item['logo'] = get_cover($item['logo'], 'url');
            $item['sharepic'] = get_cover($item['sharepic'], 'url');
        }
        $result['indexopen1'] = C('INDEXOPEN1');
        $result['indexopen2'] = C('INDEXOPEN2');
        $result['indexopen3'] = C('INDEXOPEN3');
        $result['sitelogo'] = get_cover(C('SITE_LOGO'), 'url');
        return $result;
    }
}
